class virtual drawable_mod =
object (s)
  method virtual signal : float -> float
  method draw (x,y) (t0,t1) max_amp =
    let step = (t1 -. t0)/.(float (128*x)) in
    let val2point (fx,fy) = (
      int_of_float((fx -. t0)/. (128.*.step)),
      (int_of_float ((fy /. max_amp)  *. (float y))) + y/2
    ) in
    begin
      Graphics.open_graph (" "^(string_of_int x)^"x"^(string_of_int y));
      Graphics.clear_graph ();
      let t = ref t0 in
	while !t<=t1 do
	  let (a,b) = val2point (!t, s#signal !t) in
	    Graphics.plot a b;
	    t := !t +. step;
	done;
	ignore (Graphics.read_key ());
	Graphics.close_graph ();
    end
end


class drawable_simple_modulator a f p =
object
  inherit SimpleModulator.simple_modulator a f p
  inherit drawable_mod
end

class drawable_env_modulator env f p =
object
  inherit SimpleModulator.env_modulator env f p
  inherit drawable_mod
end

class drawable_simple_add m1 m2 =
object
  inherit Addict.simple_add m1 m2
  inherit drawable_mod
end

